package com.xiaoma.pattern.proxy.jdk;

import java.lang.reflect.Proxy;

public class ProxyFactory<T> {



    @SuppressWarnings("unchecked")
    protected static <T> Object newInstance(Class<T> mapperInterface,MyProxy<T> myProxy) {
        return  Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[]{mapperInterface}, myProxy);
    }

//    public static void main(String[] args) {
//        IHello iHello = ProxyFactory<IHello>(IHello.class).newInstance(new MyProxy<>(new Hello()));
//        iHello.sayHello();
//    }

}
